home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / scherz programme / clicker / source / sound.h < prev    next >
C/C++ Source or Header  |  1996-04-07  |  2KB  |  76 lines

  1. /*  File:         sound.h
  2.  *  Created:      20-10-95
  3.  *  Updated:      30-12-95
  4.  *  Version:      1.0
  5.  *  Project:      Clicker
  6.  *  Owner:        Jeroen Vermeulen
  7.  *  Requirements: KickStart V39+
  8.  *  Legal:        PD
  9.  *  Status:       Release
  10.  */
  11.  
  12. #define SAMPLELENGTH 12
  13.  
  14.  
  15.  
  16. /* CreateSample():
  17.  * Open audio device and sample.  An IOAudio structure is returned unless either
  18.  * an error occurs or the error string was already non-NULL before the call.
  19.  */
  20. struct IOAudio *CreateSample(STRPTR *const error);
  21.  
  22.  
  23. /* Destroy sample and free all resources allocated with it.  This function is
  24.  * overly robust so it can be used from within CreateSample() in case of an
  25.  * error.
  26.  */
  27. void DeleteSample(struct IOAudio *const soundrequest);
  28.  
  29.  
  30. /* KeyClick():
  31.  * Make key-click noise.  The soundrequest pointer is assumed to be valid and
  32.  * non-NULL, and point at a properly initialized IOAudio structure.
  33.  */
  34. void KeyClick(struct IOAudio *const soundrequest);
  35.  
  36.  
  37. /* SliderToHertz():
  38.  * Converts a prefs window slider position (between -5*12 and 4*12) to a
  39.  * frequency in Hertz, based on a twelve-tone octave centered at the 440 Hz A.
  40.  * This function is forced to take an unused Gadget parameter and to return LONG
  41.  * because it is passed to gadtools.library as a hook function.
  42.  */
  43. LONG SliderToHertz(const struct Gadget *const dum, const WORD sliderpos);
  44.  
  45.  
  46. /* HertzToPeriod():
  47.  * Converts human-readable pitch in Hertz to period length suitable for use by
  48.  * audio.device.  As a rule, HertzToPeriod(SliderToHertz(S)) is equivalent to
  49.  * SliderToPeriod(S).
  50.  */
  51. UWORD HertzToPeriod(const LONG Hertz);
  52.  
  53.  
  54. /* PeriodToHertz():
  55.  * Converts audio.device period length to human-readable pitch in Hertz.  This
  56.  * is the inverse of HertzToPeriod().  It needs to return LONG, so exact Hertz
  57.  * settings aren't possible.
  58.  */
  59. LONG PeriodToHertz(const UWORD period);
  60.  
  61.  
  62. /* SliderToPeriod():
  63.  * Converts a prefs window slider position (between 0 and 9*12) to a period
  64.  * length (in units of 279.365 nanoseconds) suitable for use by audio.device.
  65.  */
  66. UWORD SliderToPeriod(const WORD sliderpos);
  67.  
  68.  
  69. /* PeriodToSlider():
  70.  * Inverse of SliderToPeriod().  Takes a period length as an argument and
  71.  * computes the appropriate slider position (between -5*12 and 4*12).  This
  72.  * function can afford to be slow because it's only ever called when the prefs
  73.  * window pops up.
  74.  */
  75. WORD PeriodToSlider(const UWORD period);
  76.